home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2000 #5
/
Amiga Plus CD - 2000 - No. 5.iso
/
Tools
/
Dev
/
Real
/
gui
/
realprefs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-25
|
7KB
|
262 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Miîosîaw Smyk
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include <clib/diskfont_protos.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/gadtools_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/utility_pragmas.h>
#include "realprefs.h"
struct Screen *Scr = NULL;
UBYTE *PubScreenName = NULL;
APTR VisualInfo = NULL;
struct Window *RealPrefsWnd = NULL;
struct Gadget *RealPrefsGList = NULL;
struct IntuiMessage RealPrefsMsg;
struct Gadget *RealPrefsGadgets[4];
UWORD RealPrefsLeft = 250;
UWORD RealPrefsTop = 265;
UWORD RealPrefsWidth = 263;
UWORD RealPrefsHeight = 49;
UBYTE *RealPrefsWdt = (UBYTE *)"wfmhcybergfx_r3d.library";
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
struct TextFont *RealPrefsFont = NULL;
UBYTE *Gadget000Labels[] = {
(UBYTE *)"Floyd-Steinberg",
(UBYTE *)"Ordered 4x4",
(UBYTE *)"None",
NULL };
UWORD RealPrefsGTypes[] = {
CYCLE_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND
};
struct NewGadget RealPrefsNGad[] = {
92, 6, 160, 14, (UBYTE *)"_Dithering", NULL, GD_Gadget00, PLACETEXT_LEFT, NULL, (APTR)Gadget00Clicked,
12, 30, 76, 14, (UBYTE *)"_Save", NULL, GD_Gadget10, PLACETEXT_IN, NULL, (APTR)Gadget10Clicked,
176, 30, 76, 14, (UBYTE *)"_Cancel", NULL, GD_Gadget20, PLACETEXT_IN, NULL, (APTR)Gadget20Clicked,
94, 30, 76, 14, (UBYTE *)"_Use", NULL, GD_Gadget30, PLACETEXT_IN, NULL, (APTR)Gadget30Clicked
};
ULONG RealPrefsGTags[] = {
(GTCY_Labels), (ULONG)&Gadget000Labels[ 0 ], (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Forbid();
Font = &Attr;
Font->ta_Name = (STRPTR)GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
FontX = GfxBase->DefaultFont->tf_XSize;
Permit();
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
ComputeFont( 0, 0 );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
void RealPrefsRender( void )
{
ComputeFont( RealPrefsWidth, RealPrefsHeight );
DrawBevelBox( RealPrefsWnd->RPort, OffX + ComputeX( 0 ),
OffY + ComputeY( 0 ),
ComputeX( 263 ),
ComputeY( 49 ),
GT_VisualInfo, VisualInfo, TAG_DONE );
}
int HandleRealPrefsIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( RealPrefsWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&RealPrefsMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( RealPrefsMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( RealPrefsWnd );
RealPrefsRender();
GT_EndRefresh( RealPrefsWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = RealPrefsCloseWindow();
break;
case IDCMP_GADGETUP:
func = ( void * )(( struct Gadget * )RealPrefsMsg.IAddress )->UserData;
running = func();
break;
}
}
return( running );
}
int OpenRealPrefsWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = RealPrefsLeft, wtop = RealPrefsTop, ww, wh;
ComputeFont( RealPrefsWidth, RealPrefsHeight );
ww = ComputeX( RealPrefsWidth );
wh = ComputeY( RealPrefsHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( RealPrefsFont = OpenDiskFont( Font )))
return( 5L );
if ( ! ( g = CreateContext( &RealPrefsGList )))
return( 1L );
for( lc = 0, tc = 0; lc < RealPrefs_CNT; lc++ ) {
CopyMem((char * )&RealPrefsNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
RealPrefsGadgets[ lc ] = g = CreateGadgetA((ULONG)RealPrefsGTypes[ lc ], g, &ng, ( struct TagItem * )&RealPrefsGTags[ tc ] );
while( RealPrefsGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( RealPrefsWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, CYCLEIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, RealPrefsGList,
WA_Title, RealPrefsWdt,
WA_ScreenTitle, "wfmhcybergfx.library ©1995-96 Miloslaw Smyk",
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( RealPrefsWnd, NULL );
RealPrefsRender();
return( 0L );
}
void CloseRealPrefsWindow( void )
{
if ( RealPrefsWnd ) {
CloseWindow( RealPrefsWnd );
RealPrefsWnd = NULL;
}
if ( RealPrefsGList ) {
FreeGadgets( RealPrefsGList );
RealPrefsGList = NULL;
}
if ( RealPrefsFont ) {
CloseFont( RealPrefsFont );
RealPrefsFont = NULL;
}
}